<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
 '
 ' Copyright 2007 Liu, Xiaokang <4341322@gmail.com>
 ' Blog <http://www.ioio.name/>
 ' 
 ' This file is part of JOS(Judge Online System).
 ' You can see this project at <http://code.google.com/p/judgeonline/>
 ' 
 ' JOS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as
 ' published by the Free Software Foundation; either revision 3 of the License, or (at your option) any later revision.
 ' 
 ' JOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 ' 
 ' You should have received a copy of the GNU General Public License along with JOS. if not, see
 ' <http://www.gnu.org/licenses/>.
 '
%>
<%Option Explicit%>
<%
	Dim PageTitle
	PageTitle="Ranklist"
%>
<!--#include file="Header.asp"-->
<div id="Main">
<div id="Problems">
<div id="ProblemsTitle">Ranklist</div>
  <%
  	    Dim Rankr
		conn.Open connstr
		Set Rankr = Server.CreateObject("ADODB.Recordset")
		Rankr.Open "SELECT * FROM [RankList]",conn,1,3 

   %>
    <table border="0" id="RecordList" align="center" style="border-bottom:#879BFF 1px dashed">
      <tr bgcolor=pink>
        <td>Rank</td>
        <td>Author</td>
        <td width="300px;">Motto</td>
        <td>Solved</td>
        <td>Submitted</td>
        <td>AC Ratio</td>
      </tr>      
	  	  <%
		  If Not Rankr.eof and Not Rankr.Bof then
		  Dim i
		  i=0
		  Do While Not Rankr.eof
		  %>
      <tr <% if i mod 2=1 then %>bgcolor=#D7EBFF><%else%>>
	  <%end if
	  i=i+1
	  
	  	Dim MemberRs
		Set MemberRs = Server.CreateObject("ADODB.Recordset")
		MemberRs.Open "SELECT * FROM [Members] WHERE Uid="+CStr(Rankr("Uid")),conn,1,3
	  %>
        <td><%=i%></td>
        <td><a href="User_Status.asp?Uid=<%=Rankr("Uid")%>"><%=MemberRs("Username")%></a></td>
        <td><%=MemberRs("Signature")%></td>
        <%
		MemberRs.Close
		set MemberRs=nothing
		
		Dim ProblemRs,ProblemNum
		Set ProblemRs = Server.CreateObject("ADODB.Recordset")
		ProblemRs.Open "SELECT COUNT([Rid]) AS subpro FROM [Records] WHERE Cid=0 and Uid="+CStr(Rankr("Uid")),conn,1,3
		ProblemNum=ProblemRs("subpro")
		ProblemRs.Close
		set ProblemRs=nothing
		%>
        <td><%=Rankr("ProblemNum")%></td>
        <td><%=ProblemNum%></td>
        <td><%=round(Rankr("ProblemNum")/(ProblemNum+0.0000001)*100)%>%</td>
      </tr>
	  <% 
	  Rankr.movenext
	  Loop
	  Else
	  %>
     <tr>
        <td colspan="9">No Record</td>
      </tr>
      <%End If%>
    </table>
	<%Dim MinRid,MaxRid
	MinRid=0
	MaxRid=0%>
         <div>&lt;&lt; First Page&nbsp;&nbsp;&nbsp;&nbsp;<a href="?PrevPage=<%=MaxRid%>">&lt;Prev Page</a>&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="?NextPage=<%=MinRid%>">Next Page&gt;</a>&nbsp;&nbsp;&nbsp;&nbsp;Last Page &gt;&gt;</div>
	<%
		Rankr.Close
		set Rankr=nothing 
		conn.Close
   %>
  </div>
</div>
<!--#include file="Footer.asp"-->